public class MC_SendEmailsController
{
    public class MC_Exception extends Exception { }
    public PageReference load()
    {
        String token=ApexPages.currentPage().getParameters().get('token');
        if(token=='YouMayRun321')
            MC_OutgoingEmail.SendLeaderEmails();
        else
            throw new MC_Exception('Invalid token provided');
        return null;
    }
    
    public static testmethod void Test1()
    {
        Test.setCurrentPage(Page.MC_SendEmails);
        Boolean caught_exception;
        
        MC_SendEmailsController controller=new MC_SendEmailsController();
        
        caught_exception=false;
        try
        {
            controller.load();
        }
        catch(MC_Exception e)
        {
            caught_exception=true;
        }
        System.assertEquals(true, caught_exception);
        
        ApexPages.currentPage().getParameters().put('token', 'Invalid');
        caught_exception=false;
        try
        {
            controller.load();
        }
        catch(MC_Exception e)
        {
            caught_exception=true;
        }
        System.assertEquals(true, caught_exception);
        
        ApexPages.currentPage().getParameters().put('token', 'YouMayRun321');
        caught_exception=false;
        try
        {
            controller.load();
        }
        catch(MC_Exception e)
        {
            caught_exception=true;
        }
        System.assertEquals(false, caught_exception);
    }
}